#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 5000010;
int a[N];
int k;
void qsort(int l, int r) {
    int i = l, j = r;
    int mid = a[(l + r) / 2];
    while(i <= j) {
        while(a[i] < mid) {
            i++;
        }
        while(a[j] > mid) {
            j--;
        }
        if(i <= j) {
            swap(a[i], a[j]);
            i++;
            j--;
        }
    }
    if(k <= j) {
        qsort(l, j);
    }else if(k >= i) {
        qsort(i, r);
    }else {
        printf("%d", a[j + 1]);
        return;
    }
}
int main() {
    int n;
    scanf("%d %d", &n, &k);
    int i = 0;
    for(; i < n; i++) {
        int temp;
        scanf("%d", &temp);
        a[i] = temp;
    }
    qsort(0, n - 1);  
    return 0;
}